package errmsg

const (
	SUCCESS = 200
	ERROR   = 500

	//code = 1000...用户模块的错误

	ERROR_USERNAME_USED      = 1001
	ERROR_PASSWORD_WRONG     = 1002
	ERROR_USER_NOT_EXIST     = 1003
	ERROR_TOKEN_EXIST        = 1004
	ERROR_TOKEN_RUNTIME      = 1005
	ERROR_TOKEN_WRONG        = 1006
	ERROR_TOKEN_TYPE_WRONG   = 1007
	ERROR_USER_NO_PERMISSION = 1008
	//code = 2000...文章模块的错误
	ERROR_ARTICLE_NOT_EXIST = 2001
	//code = 3000...分类模块的错误
	ERROR_CATENAME_USED  = 3001
	ERROR_CATE_NOT_EXIST = 3002

	//FILES_UPLOAD_SUCCESS  = 4001
	FILES_UPLOAD_FAILED = 4002
	//FILES_GETLIST_SUCCESS = 4003
	FILES_GETLIST_FAILED = 4004
	//FILES_DELETE_SUCCESS  = 4200
	FILES_DELETE_FAILED  = 4006
	FILES_ALERDYA_DELETE = 4612
)

var codemsg = map[int]string{
	SUCCESS:                  "OK",
	ERROR:                    "FAIL",
	ERROR_USERNAME_USED:      "用户名已存在",
	ERROR_PASSWORD_WRONG:     "密码错误",
	ERROR_USER_NOT_EXIST:     "用户不存在",
	ERROR_USER_NO_PERMISSION: "该用户没有权限",
	ERROR_TOKEN_EXIST:        "TOKEN不存在",
	ERROR_TOKEN_RUNTIME:      "TOKEN已过期",
	ERROR_TOKEN_WRONG:        "TOKEN不正确",
	ERROR_TOKEN_TYPE_WRONG:   "TOKEN格式错误",

	ERROR_ARTICLE_NOT_EXIST: "文章不存在",
	ERROR_CATENAME_USED:     "该分类已存在",
	ERROR_CATE_NOT_EXIST:    "该分类不存在",

	//FILES_UPLOAD_SUCCESS:  "文件上传成功",
	FILES_UPLOAD_FAILED: "文件上传失败",
	//FILES_GETLIST_SUCCESS: "获取文件列表成功",
	FILES_GETLIST_FAILED: "获取文件列表失败",
	//FILES_DELETE_SUCCESS:  "删除文件成功",
	FILES_DELETE_FAILED:  "删除文件失败",
	FILES_ALERDYA_DELETE: "文件已删除无需重复删除",
}

func GetErrMsg(code int) string {
	return codemsg[code]
}
